package com.hdu.point_offer;

public class lc139 {
    class Solution {
        public int[] trainingPlan(int[] actions) {
            int l = 0 , r = actions.length - 1;
            while (l < r)
            {
                while (l < r && actions[r] % 2 == 0)
                {
                    r--;
                }
                while (l < r && actions[l] % 2 == 1)
                {
                    l++;
                }
                if (l == r) break;
                swap(actions, l, r);
            }
            return actions;
        }

        void swap(int[] nums, int i, int j)
        {
            int temp = nums[i];
            nums[i] = nums[j];
            nums[j] = temp;
        }
    }
}
